<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Create</title>
</head>
<body>
    <button onclick="test1()">Instance1请求</button>
    <button onclick="test2()">Instance2请求</button>
<br/>
    <div id="result"></div>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.js"></script>
    <script>
        const resutl = document.getElementById('result');
        axios.defaults.baseURL = 'http://localhost:9001'
        function test1(params){
            axios({
                url:'/posts',
                params: {
                    id: 1
                }
            }).then(response => {
                console.log(response);
                resutl.innerText = JSON.stringify(response.data);
            });
        }

        const instance = axios.create({
            baseURL: 'http://localhost:9001/posts/2'
        });

        function test2(params){
            instance(
                {}
            ).then(response => {
                console.log(response);
                resutl.innerText = JSON.stringify(response.data);
            });
        }
    </script>

</body>
</html>